using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Book_List  -  书签 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IBookList<T> :ModelBase<BookList> where T : BookList, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.BookId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return BookId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.BookId=dy.BookId;
           this.Title=dy.Title;
           this.Url=dy.Url;
           this.SubmitTime=dy.SubmitTime;
           this.IsRecommend=dy.IsRecommend;
           this.CloseRecomTime=dy.CloseRecomTime;
           this.Support=dy.Support;
           this.Version=dy.Version;
           this.Detailed=dy.Detailed;
        } 

        #region 定义属性

     
         /// <summary>
        /// 书签ID
        /// </summary>
        private String _BookId = "";
      
        /// <summary>
        /// 书签ID
        /// </summary>
        public String BookId
        {
            get 
            {
              return   (this._BookId); 
            }

            set 
            {
                    _BookId= value;  
            }
        }
       
     
         /// <summary>
        /// 标题
        /// </summary>
        private String _Title = "";
      
        /// <summary>
        /// 标题
        /// </summary>
        public String Title
        {
            get 
            {
              return   (this._Title); 
            }

            set 
            {
                    _Title= value;  
            }
        }
       
     
         /// <summary>
        /// Url地址
        /// </summary>
        private String _Url = "";
      
        /// <summary>
        /// Url地址
        /// </summary>
        public String Url
        {
            get 
            {
              return   (this._Url); 
            }

            set 
            {
                    _Url= value;  
            }
        }
       
     
         /// <summary>
        /// 创建时间
        /// </summary>
        private DateTime _SubmitTime =DateTime.MinValue;
      
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime SubmitTime
        {
            get 
            {
              return   (this._SubmitTime); 
            }

            set 
            {
                    _SubmitTime= value;  
            }
        }
       
     
         /// <summary>
        /// 是否推荐
        /// </summary>
        private int _IsRecommend =-1;
      
        /// <summary>
        /// 是否推荐
        /// </summary>
        public yq.Enums.BooleanType IsRecommend
        {
            get 
            {
              return  (yq.Enums.BooleanType)_IsRecommend; 
            }

            set 
            {
                    _IsRecommend= value.GetHashCode(); 
            }
        }
       
     
         /// <summary>
        /// 推荐到期时间
        /// </summary>
        private DateTime _CloseRecomTime =DateTime.MinValue;
      
        /// <summary>
        /// 推荐到期时间
        /// </summary>
        public DateTime CloseRecomTime
        {
            get 
            {
              return   (this._CloseRecomTime); 
            }

            set 
            {
                    _CloseRecomTime= value;  
            }
        }
       
     
         /// <summary>
        /// 支持人数
        /// </summary>
        private int _Support =int.MinValue;
      
        /// <summary>
        /// 支持人数
        /// </summary>
        public int Support
        {
            get 
            {
              return   (this._Support); 
            }

            set 
            {
                    _Support= value;  
            }
        }
       
     
       
     
         /// <summary>
        /// 说明
        /// </summary>
        private String _Detailed = "";
      
        /// <summary>
        /// 说明
        /// </summary>
        public String Detailed
        {
            get 
            {
              return   (this._Detailed); 
            }

            set 
            {
                    _Detailed= value;  
            }
        }
       

      #endregion 定义属性 

          protected internal override void SetValue(BookList info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["BookId"]!= DBNull.Value)
                  {
                  info.BookId=row["BookId"].ToString();
                 }
                 
                  
                  if(row["Title"]!= DBNull.Value)
                  {
                  info.Title=row["Title"].ToString();
                 }
                 
                  
                  if(row["Url"]!= DBNull.Value)
                  {
                  info.Url=row["Url"].ToString();
                 }
                 
                  
                  if(row["SubmitTime"]!= DBNull.Value)
                  {
                  info.SubmitTime=Convert.ToDateTime(row["SubmitTime"]);
                 }
                 
                  
                  if(row["IsRecommend"]!= DBNull.Value)
                  {
                  info.IsRecommend= (yq.Enums.BooleanType)(row["IsRecommend"]) ;
                 }
                 
                  
                  if(row["CloseRecomTime"]!= DBNull.Value)
                  {
                  info.CloseRecomTime=Convert.ToDateTime(row["CloseRecomTime"]);
                 }
                 
                  
                  if(row["Support"]!= DBNull.Value)
                  {
                  info.Support=Convert.ToInt32(row["Support"]);
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
                  
                  if(row["Detailed"]!= DBNull.Value)
                  {
                  info.Detailed=row["Detailed"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, BookList info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@BookId", DbType.String,ParameterTool.GetObj( info._BookId )); 
            
             
                cn.AddInParameter(comm, "@Title", DbType.String,ParameterTool.GetObj( info._Title )); 
            
             
                cn.AddInParameter(comm, "@Url", DbType.String,ParameterTool.GetObj( info._Url )); 
            
             
                cn.AddInParameter(comm, "@SubmitTime", DbType.DateTime,ParameterTool.GetObj( info._SubmitTime )); 
            
             
                cn.AddInParameter(comm, "@IsRecommend", DbType.Int32,ParameterTool.GetObj( info._IsRecommend )); 
            
             
                cn.AddInParameter(comm, "@CloseRecomTime", DbType.DateTime,ParameterTool.GetObj( info._CloseRecomTime )); 
            
             
                cn.AddInParameter(comm, "@Support", DbType.Int32,ParameterTool.GetObj( info._Support )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
             
                cn.AddInParameter(comm, "@Detailed", DbType.String,ParameterTool.GetObj( info._Detailed )); 
            
        } 

    } 
} 